using System;
using System.Data;
using System.Collections.Generic;

namespace SERP.DAO{
	/********************************BEGIN SalaryRulePeopleDAO****************************************/
	///<summary>
	/// <para>Author: Auto generated class by CSharp Code Generator v2.0</para>
	/// <para>Date:09/03/2013 19:09:04</para>
	/// <para>Class Name: SalaryRulePeopleDAO</para>
	/// <para>Description: Class access to table SalaryRulePeople in database. Coder should'nt code here.</para>
	///</summary>

	
	public partial class SalaryRulePeopleDAO : DAOBase<SalaryRulePeopleEntity>{


		#region Select functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectOneCommand</para>
		/// <para>Input: SalaryRulePeopleId</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectOneCommand(int SalaryRulePeopleId){
			string strSQL="SELECT  [SalaryRulePeopleId],[SalaryRuleId],[PersonId] FROM [SalaryRulePeople]  WHERE [SalaryRulePeople].[SalaryRulePeopleId]=@SalaryRulePeopleId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@SalaryRulePeopleId",SalaryRulePeopleId);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectOne</para>
		/// <para>Input: SalaryRulePeopleId</para>
		/// <para>Output: SalaryRulePeopleEntity</para>
		///</summary>
		public SalaryRulePeopleEntity SelectOne(int SalaryRulePeopleId){
			IDbCommand cmd=this.CreateSelectOneCommand(SalaryRulePeopleId);
			return this.Select(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllCommand(){
			string strSQL="SELECT  [SalaryRulePeopleId],[SalaryRuleId],[PersonId] FROM [SalaryRulePeople] ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectAllByKeyCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyCommand(string ColumnName,object Value){
			string strSQL="SELECT  [SalaryRulePeopleId],[SalaryRuleId],[PersonId] FROM [SalaryRulePeople]  WHERE [SalaryRulePeople].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of SalaryRulePeopleEntity</para>
		///</summary>
		public List<SalaryRulePeopleEntity> SelectAll(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectAllDS</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDS(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectDS(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectAllFilterCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllFilterCommand(string strFilter){
			string strSQL="SELECT  [SalaryRulePeopleId],[SalaryRuleId],[PersonId] FROM [SalaryRulePeople]  WHERE "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectAllByKeyFilterCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyFilterCommand(string strFilter,string ColumnName,object Value){
			string strSQL="SELECT  [SalaryRulePeopleId],[SalaryRuleId],[PersonId] FROM [SalaryRulePeople]  WHERE [SalaryRulePeople].["+ColumnName+"]=@ColumnName AND "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of SalaryRulePeopleEntity</para>
		///</summary>
		public List<SalaryRulePeopleEntity> SelectAllFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectAllDSFilter</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDSFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectDS(cmd);
		}
		#endregion

		#region Insert functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateInsertCommand</para>
		/// <para>Input: SalaryRulePeopleEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateInsertCommand(SalaryRulePeopleEntity o){
			string strSQL="INSERT INTO [SalaryRulePeople]([SalaryRuleId],[PersonId]) VALUES  (@SalaryRuleId,@PersonId);SELECT  @@IDENTITY";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullSalaryRuleId)
				this.CreateCommandParameter(cmd,"@SalaryRuleId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SalaryRuleId",o.SalaryRuleId);

			if(o.IsNullPersonId)
				this.CreateCommandParameter(cmd,"@PersonId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PersonId",o.PersonId);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: Save</para>
		/// <para>Input: SalaryRulePeopleEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Save(SalaryRulePeopleEntity o){
			bool result=false;
			IDbCommand cmd=this.CreateInsertCommand(o);
			object id=this.ExecuteScalar(cmd,ref result);
			cmd.Dispose();
			try{
				o.SalaryRulePeopleId=int.Parse(Convert.ToString(id));
			}
			catch{}
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SaveList</para>
		/// <para>Input: List of SalaryRulePeopleEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void SaveList(List<SalaryRulePeopleEntity>list){
			foreach(SalaryRulePeopleEntity o in list){
				try{
					this.Save(o);
				}
				catch{
				}
			}
		}
		#endregion

		#region Update functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateUpdateCommand</para>
		/// <para>Input: SalaryRulePeopleEntity</para>
		/// <para>Output: </para>
		///</summary>
		protected IDbCommand CreateUpdateCommand(SalaryRulePeopleEntity o){
			string strSQL="UPDATE  [SalaryRulePeople] SET [SalaryRulePeople].[SalaryRuleId]=@SalaryRuleId,[SalaryRulePeople].[PersonId]=@PersonId WHERE [SalaryRulePeople].[SalaryRulePeopleId]=@SalaryRulePeopleId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullSalaryRuleId)
				this.CreateCommandParameter(cmd,"@SalaryRuleId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SalaryRuleId",o.SalaryRuleId);

			if(o.IsNullPersonId)
				this.CreateCommandParameter(cmd,"@PersonId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PersonId",o.PersonId);

			if(o.IsNullSalaryRulePeopleId)
				this.CreateCommandParameter(cmd,"@SalaryRulePeopleId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SalaryRulePeopleId",o.SalaryRulePeopleId);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateUpdateFieldCommand</para>
		/// <para>Input: ColumnName,ColumnValue,SalaryRulePeopleId</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateUpdateFieldCommand(string ColumnName,object Value,int SalaryRulePeopleId){
			string strSQL="UPDATE  [SalaryRulePeople] SET [SalaryRulePeople].["+ColumnName+"]=@ColumnName WHERE [SalaryRulePeople].[SalaryRulePeopleId]=@SalaryRulePeopleId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@SalaryRulePeopleId",SalaryRulePeopleId);



			this.CreateCommandParameter(cmd,"@ColumnName",Value);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: Update</para>
		/// <para>Input: SalaryRulePeopleEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Update(SalaryRulePeopleEntity o){
			IDbCommand cmd=this.CreateUpdateCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateList</para>
		/// <para>Input: List of SalaryRulePeopleEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void UpdateList(List<SalaryRulePeopleEntity>list){
			foreach(SalaryRulePeopleEntity o in list){
				try{
					this.Update(o);
				}
				catch{
				}
			}
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateSalaryRuleId</para>
		/// <para>Input: NewSalaryRuleId,SalaryRulePeopleId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateSalaryRuleId(int NewSalaryRuleId,int SalaryRulePeopleId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("SalaryRuleId",NewSalaryRuleId,SalaryRulePeopleId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdatePersonId</para>
		/// <para>Input: NewPersonId,SalaryRulePeopleId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdatePersonId(int NewPersonId,int SalaryRulePeopleId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("PersonId",NewPersonId,SalaryRulePeopleId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Delete functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: DeleteAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteAllCommand(){
			string strSQL="DELETE   FROM [SalaryRulePeople]  ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: DeleteCommand</para>
		/// <para>Input: SalaryRulePeopleEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteCommand(SalaryRulePeopleEntity o){
			string strSQL="DELETE   FROM [SalaryRulePeople]   WHERE [SalaryRulePeople].[SalaryRulePeopleId]=@SalaryRulePeopleId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullSalaryRulePeopleId)
				this.CreateCommandParameter(cmd,"@SalaryRulePeopleId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SalaryRulePeopleId",o.SalaryRulePeopleId);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: DeleteAll</para>
		/// <para>Input: </para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteAll(){
			IDbCommand cmd=this.CreateDeleteAllCommand();
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateDeleteByPrimaryKeyCommand</para>
		/// <para>Input: SalaryRulePeopleId</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByPrimaryKeyCommand(int SalaryRulePeopleId){
			string strSQL="DELETE   FROM [SalaryRulePeople]   WHERE [SalaryRulePeople].[SalaryRulePeopleId]=@SalaryRulePeopleId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@SalaryRulePeopleId",SalaryRulePeopleId);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateDeleteByKeyCommand</para>
		/// <para>Input: ColumnName , ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByKeyCommand(string ColumnName,object Value){
			string strSQL="DELETE   FROM [SalaryRulePeople]   WHERE [SalaryRulePeople].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: Delete</para>
		/// <para>Input: SalaryRulePeopleEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Delete(SalaryRulePeopleEntity o){
			IDbCommand cmd=this.CreateDeleteCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: DeleteByID</para>
		/// <para>Input: SalaryRulePeopleId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteByID(int SalaryRulePeopleId){
			IDbCommand cmd=this.CreateDeleteByPrimaryKeyCommand(SalaryRulePeopleId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Select join to PeopleSalaryRules functions
		#endregion

		#region Select join to People functions
		#endregion

		#region Select join to SalaryRules functions
		#endregion

		#region Select,delete by SalaryRulePeopleId functions
		#endregion

		#region Select,delete by SalaryRuleId functions
		#endregion

		#region Select,delete by PersonId functions
		#endregion

		#region MapObject functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: MapObject</para>
		/// <para>Input: IDataReader</para>
		/// <para>Output: SalaryRulePeopleEntity</para>
		///</summary>
		protected override SalaryRulePeopleEntity MapObject(IDataReader r){
			SalaryRulePeopleEntity entity = new SalaryRulePeopleEntity();
			try{
				if(r.FieldCount>0){
					try
					{
						int ordinal = r.GetOrdinal("SalaryRulePeopleId");
						if (!r.IsDBNull(ordinal)) entity.SalaryRulePeopleId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("SalaryRuleId");
						if (!r.IsDBNull(ordinal)) entity.SalaryRuleId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("PersonId");
						if (!r.IsDBNull(ordinal)) entity.PersonId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					return entity;
				}
			}catch{}
			return null;
		}
		#endregion
	}
	/*****************************************************************************************************/
	/**********************************END SalaryRulePeopleDAOBase*****************************************/
	/*****************************************************************************************************/
}

